﻿Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports Microsoft.SqlServer.Server
Imports FileManipulationSQLCLRExternal.SharedObjects

Partial Public Class StoredProcedures
    <Microsoft.SqlServer.Server.SqlProcedure()> _
    Shared Function MSPGetFileSpecs(ByVal FilePath As SqlString, _
                                    ByVal FileName As SqlString, _
                                    ByRef FileSize As SqlInt32, _
                                    ByRef FileDt As SqlDateTime, _
                                    ByRef FileExistFlag As SqlByte) As Integer
        Try
            Dim _iFileSize As Integer
            Dim _dFileDt As Date
            Dim _bFileExistFlag As Boolean

            GetFileSpecs(CType(FileName, String), CType(FilePath, String), _iFileSize, _dFileDt, _bFileExistFlag)

            If _bFileExistFlag = True Then
                FileSize = CType(_iFileSize, SqlInt32)
                FileDt = CType(_dFileDt, SqlDateTime)
                FileExistFlag = CType(1, SqlByte)
            Else
                FileSize = SqlInt32.Null
                FileDt = SqlDateTime.Null
                FileExistFlag = CType(0, SqlByte)
            End If

            Return 0
        Catch sqlex As SqlException
            ShowError(sqlex.ToString)

            Return 1
        Catch ex As Exception
            ShowError(ex.ToString)

            Return 1
        End Try
    End Function
End Class
